/*
 * Created by JFormDesigner on Tue Aug 02 19:55:55 CST 2022
 */

package client.userMange;

import client.util.ClientConn;
import command.Command;
import command.userComm.companyCommand.*;
import command.userComm.departmentCommand.*;
import command.userComm.userCommand.*;
import empty.users.Company;
import empty.users.Department;
import empty.users.User;
import model.userModel.CompanyModel;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.util.List;

/**
 * @author Brainrain
 */
public class UserMange extends JFrame {
    public static void main(String[] args) throws Exception {
        UserMange userMange = new UserMange();
        userMange.setVisible(true);
        userMange.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public UserMange() throws Exception {
        initComponents();
        cc.connect();
    }

    private CompanyModel cm = new CompanyModel();
    private Company co = new Company();
    private Department dt = new Department();
    private User u = new User();
    private ClientConn cc = new ClientConn();

    private void insert(ActionEvent e) {
        try {
            Command cic = new CompanyInsertCommand();
            Company co = new Company();
            co.setName(textField2.getText());
            co.setAddress(textField3.getText());
            co.setMaster(textField4.getText());
            co.setPhone(Integer.parseInt(textField5.getText()));
            cic.o = co;
            cc.send(cic);
            cic = (Command) cc.receive();
            if(cic.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"insert" + cic.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void delete(ActionEvent e) {
        try {
            Command cic = new CompanyDeleteCommand();
            Company co = new Company();
            co.setId(Integer.parseInt(textField1.getText()));
            cic.o = co;
            cc.send(cic);
            cic = (Command) cc.receive();
            if(cic.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"delete" + cic.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void update(ActionEvent e) {
        try {
            Command cic = new CompanyUpdateCommand();
            Company co = new Company();
            co.setId(Integer.parseInt(textField1.getText()));
            co.setName(textField2.getText());
            co.setAddress(textField3.getText());
            co.setMaster(textField4.getText());
            co.setPhone(Integer.parseInt(textField5.getText()));
            cic.o = co;
            cc.send(cic);
            cic = (Command) cc.receive();
            if(cic.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"update" + cic.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void find(ActionEvent e) {
        try {
            Command com;
            if("".equals(textField2.getText()) || textField2.getText() == null){
                com = new CompanyFindAllCommand();
            }else {
                com = new CompanyFindByNameCommand();
                Company co = new Company();
                co.setName(textField2.getText());
                com.o = co;
            }
            cc.send(com);
            com = (Command) cc.receive();
            if(com.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                showDataInTable((List<Object []>)com.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void showDataInTable(List<Object []> r){
        DefaultTableModel dtm = new DefaultTableModel();
        table1.setModel(dtm);
        String [] header = {"ID", "名称", "地址", "法人", "联系方式"};
        Object [] [] data = new Object[r.size()][];
        for(int i = 0; i < data.length; i++){
            data[i] = r.get(i);
        }
        dtm.setDataVector(data, header);
    }

    private void Clicked(MouseEvent e) {
        TableModel tb =table1.getModel();
        int r = table1.getSelectedRow();
        textField1.setText(tb.getValueAt(r,0).toString());
        textField2.setText(tb.getValueAt(r,1).toString());
        textField3.setText(tb.getValueAt(r,2).toString());
        textField4.setText(tb.getValueAt(r,3).toString());
        textField5.setText(tb.getValueAt(r,4).toString());
    }

    private void departmentInsert(ActionEvent e) {
        try {
            Command dc = new DepartmentInsertCommand();
            Department dt = new Department();
            dt.setName(textField7.getText());
            dt.setManager(textField8.getText());
            dt.setNumber_of_people(Integer.parseInt(textField9.getText()));
            dt.setCompany_id(Integer.parseInt(textField10.getText()));
            dc.o = dt;
            cc.send(dc);
            dc = (Command) cc.receive();
            if(dc.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"insert" + dc.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void departmentDelete(ActionEvent e) {
        try {
            Command dc = new DepartmentDeleteCommand();
            Department dt = new Department();
            dt.setId(Integer.parseInt(textField6.getText()));
            dc.o = dt;
            cc.send(dc);
            dc = (Command) cc.receive();
            if(dc.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"delete" + dc.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void departmentUpdate(ActionEvent e) {
        try {
            Command dc = new DepartmentUpdateCommand();
            Department dt = new Department();
            dt.setId(Integer.parseInt(textField6.getText()));
            dt.setName(textField7.getText());
            dt.setManager(textField8.getText());
            dt.setNumber_of_people(Integer.parseInt(textField9.getText()));
            dt.setCompany_id(Integer.parseInt(textField10.getText()));
            dc.o = dt;
            cc.send(dc);
            dc = (Command) cc.receive();
            if(dc.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"update" + dc.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void departmentFind(ActionEvent e) {
        try {
            Command com;
            if("".equals(textField7.getText()) || textField7.getText() == null){
                com = new DepartmentFindAllCommand();
            }else {
                com = new DepartmentFindByNameCommand();
                Department dt = new Department();
                dt.setName(textField7.getText());
                com.o = dt;
            }
            cc.send(com);
            com = (Command) cc.receive();
            if(com.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                showDataInTable1((List<Object []>)com.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void showDataInTable1(List<Object []> r){
        DefaultTableModel dtm = new DefaultTableModel();
        table2.setModel(dtm);
        String [] header = {"ID", "部门名称", "经理", "部门人数", "公司ID"};
        Object [] [] data = new Object[r.size()][];
        for(int i = 0; i < data.length; i++){
            data[i] = r.get(i);
        }
        dtm.setDataVector(data, header);
    }

    private void userInsert(ActionEvent e) {
        try {
            Command com = new UserInsertCommand();
            User u = new User();
            u.setName(textField12.getText());
            u.setGender(textField13.getText());
            u.setAge(Integer.parseInt(textField14.getText()));
            u.setPhone(Integer.parseInt(textField15.getText()));
            u.setAddress(textField16.getText());
            u.setPwd(textField17.getText());
            u.setManger(Integer.parseInt(textField18.getText()));
            u.setDepartment_id(Integer.parseInt(textField19.getText()));
            com.o = u;
            cc.send(com);
            com = (Command) cc.receive();
            if(com.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"insert" + com.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void userDelete(ActionEvent e) {
        try {
            Command com = new UserDeleteCommand();
            User u = new User();
            u.setId(Integer.parseInt(textField11.getText()));
            com.o = u;
            cc.send(com);
            com = (Command) cc.receive();
            if(com.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"delete" + com.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void userUpdate(ActionEvent e) {
        try {
            Command com = new UserUpdateCommand();
            User u = new User();
            u.setId(Integer.parseInt(textField11.getText()));
            u.setName(textField12.getText());
            u.setGender(textField13.getText());
            u.setAge(Integer.parseInt(textField14.getText()));
            u.setPhone(Integer.parseInt(textField15.getText()));
            u.setAddress(textField16.getText());
            u.setPwd(textField17.getText());
            u.setManger(Integer.parseInt(textField18.getText()));
            u.setDepartment_id(Integer.parseInt(textField19.getText()));
            com.o = u;
            cc.send(com);
            com = (Command) cc.receive();
            if(com.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                JOptionPane.showMessageDialog(null,"update" + com.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void userFind(ActionEvent e) {
        try {
            Command com;
            if("".equals(textField12.getText()) || textField12.getText() == null){
                com = new UserFindAllCommand();
            }else {
                com = new UserFindByNameCommand();
                User u = new User();
                u.setName(textField12.getText());
                com.o = u;
            }
            cc.send(com);
            com = (Command) cc.receive();
            if(com.e != null){
                JOptionPane.showMessageDialog(null,"error");
            }else {
                showDataInTable2((List<Object []>)com.r);
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    private void showDataInTable2(List<Object []> r){
        DefaultTableModel dtm = new DefaultTableModel();
        table3.setModel(dtm);
        String [] header = {"ID", "姓名", "性别", "年龄", "联系方式", "地址", "密码", "是否是管理员", "隶属部门ID"};
        Object [] [] data = new Object[r.size()][];
        for(int i = 0; i < data.length; i++){
            data[i] = r.get(i);
        }
        dtm.setDataVector(data, header);
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        tabbedPane1 = new JTabbedPane();
        panel3 = new JPanel();
        label1 = new JLabel();
        label2 = new JLabel();
        label3 = new JLabel();
        label4 = new JLabel();
        label5 = new JLabel();
        textField1 = new JTextField();
        textField2 = new JTextField();
        textField3 = new JTextField();
        textField4 = new JTextField();
        textField5 = new JTextField();
        button1 = new JButton();
        button2 = new JButton();
        button3 = new JButton();
        button4 = new JButton();
        scrollPane1 = new JScrollPane();
        table1 = new JTable();
        panel4 = new JPanel();
        label6 = new JLabel();
        label7 = new JLabel();
        label8 = new JLabel();
        textField6 = new JTextField();
        textField7 = new JTextField();
        textField8 = new JTextField();
        textField9 = new JTextField();
        textField10 = new JTextField();
        label9 = new JLabel();
        label10 = new JLabel();
        button5 = new JButton();
        button6 = new JButton();
        button7 = new JButton();
        button8 = new JButton();
        scrollPane2 = new JScrollPane();
        table2 = new JTable();
        panel5 = new JPanel();
        label11 = new JLabel();
        label12 = new JLabel();
        label13 = new JLabel();
        label14 = new JLabel();
        label15 = new JLabel();
        label16 = new JLabel();
        label17 = new JLabel();
        label18 = new JLabel();
        label19 = new JLabel();
        textField11 = new JTextField();
        textField12 = new JTextField();
        textField13 = new JTextField();
        textField14 = new JTextField();
        textField15 = new JTextField();
        textField16 = new JTextField();
        textField17 = new JTextField();
        textField18 = new JTextField();
        textField19 = new JTextField();
        button9 = new JButton();
        button10 = new JButton();
        button11 = new JButton();
        button12 = new JButton();
        scrollPane3 = new JScrollPane();
        table3 = new JTable();

        //======== this ========
        var contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== tabbedPane1 ========
        {

            //======== panel3 ========
            {

                //---- label1 ----
                label1.setText("ID");
                label1.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label2 ----
                label2.setText("\u540d\u79f0");
                label2.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label3 ----
                label3.setText("\u5730\u5740");
                label3.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label4 ----
                label4.setText("\u6cd5\u4eba");
                label4.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label5 ----
                label5.setText("\u8054\u7cfb\u65b9\u5f0f");
                label5.setHorizontalAlignment(SwingConstants.CENTER);

                //---- button1 ----
                button1.setText("\u6ce8\u518c");
                button1.addActionListener(e -> insert(e));

                //---- button2 ----
                button2.setText("\u6ce8\u9500");
                button2.addActionListener(e -> delete(e));

                //---- button3 ----
                button3.setText("\u66f4\u6539");
                button3.addActionListener(e -> update(e));

                //---- button4 ----
                button4.setText("\u67e5\u8be2");
                button4.addActionListener(e -> find(e));

                //======== scrollPane1 ========
                {
                    scrollPane1.setViewportView(table1);
                }

                GroupLayout panel3Layout = new GroupLayout(panel3);
                panel3.setLayout(panel3Layout);
                panel3Layout.setHorizontalGroup(
                    panel3Layout.createParallelGroup()
                        .addGroup(panel3Layout.createSequentialGroup()
                            .addGap(27, 27, 27)
                            .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                .addGroup(panel3Layout.createSequentialGroup()
                                    .addComponent(label3, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(textField3))
                                .addGroup(panel3Layout.createSequentialGroup()
                                    .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                                        .addGroup(GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
                                            .addGap(37, 37, 37)
                                            .addComponent(button1)
                                            .addGap(78, 78, 78)
                                            .addComponent(button2))
                                        .addGroup(GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
                                            .addComponent(label4, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(textField4))
                                        .addGroup(GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
                                            .addComponent(label1, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(textField1, GroupLayout.PREFERRED_SIZE, 238, GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                                        .addGroup(panel3Layout.createSequentialGroup()
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                                .addGroup(panel3Layout.createSequentialGroup()
                                                    .addComponent(label2, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(textField2, GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE))
                                                .addGroup(panel3Layout.createSequentialGroup()
                                                    .addComponent(label5, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(textField5))))
                                        .addGroup(GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
                                            .addGap(45, 45, 45)
                                            .addComponent(button3)
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 114, Short.MAX_VALUE)
                                            .addComponent(button4)
                                            .addGap(43, 43, 43))))
                                .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 666, Short.MAX_VALUE))
                            .addContainerGap(30, Short.MAX_VALUE))
                );
                panel3Layout.setVerticalGroup(
                    panel3Layout.createParallelGroup()
                        .addGroup(panel3Layout.createSequentialGroup()
                            .addGap(27, 27, 27)
                            .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label1, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(label2, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label3, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label4, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(label5, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(button1)
                                .addComponent(button2)
                                .addComponent(button3)
                                .addComponent(button4))
                            .addGap(18, 18, 18)
                            .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 266, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(32, Short.MAX_VALUE))
                );
            }
            tabbedPane1.addTab("\u516c\u53f8", panel3);

            //======== panel4 ========
            {

                //---- label6 ----
                label6.setText("ID");
                label6.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label7 ----
                label7.setText("\u90e8\u95e8\u540d\u79f0");
                label7.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label8 ----
                label8.setText("\u7ecf\u7406");
                label8.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label9 ----
                label9.setText("\u90e8\u95e8\u4eba\u6570");
                label9.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label10 ----
                label10.setText("\u516c\u53f8ID");
                label10.setHorizontalAlignment(SwingConstants.CENTER);

                //---- button5 ----
                button5.setText("\u6ce8\u518c");
                button5.addActionListener(e -> departmentInsert(e));

                //---- button6 ----
                button6.setText("\u6ce8\u9500");
                button6.addActionListener(e -> departmentDelete(e));

                //---- button7 ----
                button7.setText("\u66f4\u6539");
                button7.addActionListener(e -> departmentUpdate(e));

                //---- button8 ----
                button8.setText("\u67e5\u8be2");
                button8.addActionListener(e -> departmentFind(e));

                //======== scrollPane2 ========
                {
                    scrollPane2.setViewportView(table2);
                }

                GroupLayout panel4Layout = new GroupLayout(panel4);
                panel4.setLayout(panel4Layout);
                panel4Layout.setHorizontalGroup(
                    panel4Layout.createParallelGroup()
                        .addGroup(panel4Layout.createSequentialGroup()
                            .addGap(80, 80, 80)
                            .addComponent(button5)
                            .addGap(66, 66, 66)
                            .addComponent(button6)
                            .addGap(72, 72, 72)
                            .addComponent(button7)
                            .addGap(71, 71, 71)
                            .addComponent(button8)
                            .addContainerGap())
                        .addGroup(GroupLayout.Alignment.TRAILING, panel4Layout.createSequentialGroup()
                            .addGap(31, 31, 31)
                            .addGroup(panel4Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                                .addGroup(GroupLayout.Alignment.LEADING, panel4Layout.createSequentialGroup()
                                    .addComponent(label9, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(textField9, GroupLayout.PREFERRED_SIZE, 221, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label10, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(textField10))
                                .addGroup(panel4Layout.createSequentialGroup()
                                    .addComponent(label6, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(textField6, GroupLayout.PREFERRED_SIZE, 130, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label7, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(textField7, GroupLayout.PREFERRED_SIZE, 134, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label8, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(textField8, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE))
                                .addComponent(scrollPane2, GroupLayout.Alignment.LEADING))
                            .addGap(69, 69, 69))
                );
                panel4Layout.setVerticalGroup(
                    panel4Layout.createParallelGroup()
                        .addGroup(panel4Layout.createSequentialGroup()
                            .addGroup(panel4Layout.createParallelGroup()
                                .addGroup(panel4Layout.createSequentialGroup()
                                    .addGap(28, 28, 28)
                                    .addGroup(panel4Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                        .addComponent(label6, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(label8, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(textField8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
                                .addGroup(GroupLayout.Alignment.TRAILING, panel4Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(panel4Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                        .addComponent(textField6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(label7, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(textField7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panel4Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label9, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                                .addComponent(label10, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(panel4Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(button5)
                                .addComponent(button6)
                                .addComponent(button8)
                                .addComponent(button7))
                            .addGap(18, 18, 18)
                            .addComponent(scrollPane2, GroupLayout.PREFERRED_SIZE, 278, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(41, Short.MAX_VALUE))
                );
            }
            tabbedPane1.addTab("\u90e8\u95e8", panel4);

            //======== panel5 ========
            {

                //---- label11 ----
                label11.setText("ID");
                label11.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label12 ----
                label12.setText("\u59d3\u540d");
                label12.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label13 ----
                label13.setText("\u6027\u522b");
                label13.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label14 ----
                label14.setText("\u5e74\u9f84");
                label14.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label15 ----
                label15.setText("\u8054\u7cfb\u65b9\u5f0f");
                label15.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label16 ----
                label16.setText("\u5730\u5740");
                label16.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label17 ----
                label17.setText("\u5bc6\u7801");
                label17.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label18 ----
                label18.setText("\u662f\u5426\u662f\u7ba1\u7406\u5458");
                label18.setHorizontalAlignment(SwingConstants.CENTER);

                //---- label19 ----
                label19.setText("\u96b6\u5c5e\u90e8\u95e8ID");
                label19.setHorizontalAlignment(SwingConstants.CENTER);

                //---- button9 ----
                button9.setText("\u6ce8\u518c");
                button9.addActionListener(e -> userInsert(e));

                //---- button10 ----
                button10.setText("\u6ce8\u9500");
                button10.addActionListener(e -> {
			userDelete(e);
			userDelete(e);
		});

                //---- button11 ----
                button11.setText("\u66f4\u6539");
                button11.addActionListener(e -> userUpdate(e));

                //---- button12 ----
                button12.setText("\u67e5\u8be2");
                button12.addActionListener(e -> userFind(e));

                //======== scrollPane3 ========
                {
                    scrollPane3.setViewportView(table3);
                }

                GroupLayout panel5Layout = new GroupLayout(panel5);
                panel5.setLayout(panel5Layout);
                panel5Layout.setHorizontalGroup(
                    panel5Layout.createParallelGroup()
                        .addGroup(GroupLayout.Alignment.TRAILING, panel5Layout.createSequentialGroup()
                            .addGroup(panel5Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                .addGroup(panel5Layout.createSequentialGroup()
                                    .addGap(31, 31, 31)
                                    .addComponent(scrollPane3))
                                .addGroup(panel5Layout.createSequentialGroup()
                                    .addGroup(panel5Layout.createParallelGroup()
                                        .addGroup(panel5Layout.createSequentialGroup()
                                            .addGap(82, 82, 82)
                                            .addComponent(button9)
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(button10)
                                            .addGap(81, 81, 81)
                                            .addComponent(button11))
                                        .addGroup(panel5Layout.createSequentialGroup()
                                            .addGap(31, 31, 31)
                                            .addGroup(panel5Layout.createParallelGroup()
                                                .addGroup(panel5Layout.createSequentialGroup()
                                                    .addComponent(label14, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(textField14))
                                                .addGroup(panel5Layout.createSequentialGroup()
                                                    .addComponent(label17, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(textField17))
                                                .addGroup(panel5Layout.createSequentialGroup()
                                                    .addComponent(label11, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(textField11, GroupLayout.PREFERRED_SIZE, 163, GroupLayout.PREFERRED_SIZE)
                                                    .addGap(0, 0, Short.MAX_VALUE)))
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(panel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                                .addGroup(panel5Layout.createSequentialGroup()
                                                    .addGroup(panel5Layout.createParallelGroup()
                                                        .addComponent(label12, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(label15, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE))
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addGroup(panel5Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                        .addComponent(textField12, GroupLayout.PREFERRED_SIZE, 142, GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(textField15, GroupLayout.PREFERRED_SIZE, 142, GroupLayout.PREFERRED_SIZE)))
                                                .addGroup(panel5Layout.createSequentialGroup()
                                                    .addComponent(label18, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(textField18)))))
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(panel5Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                        .addGroup(panel5Layout.createSequentialGroup()
                                            .addComponent(label16, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(textField16))
                                        .addGroup(panel5Layout.createSequentialGroup()
                                            .addComponent(label13, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(textField13, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE))
                                        .addGroup(panel5Layout.createSequentialGroup()
                                            .addComponent(label19, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(panel5Layout.createParallelGroup()
                                                .addGroup(panel5Layout.createSequentialGroup()
                                                    .addGap(6, 6, 6)
                                                    .addComponent(button12))
                                                .addComponent(textField19))))))
                            .addGap(36, 36, 36))
                );
                panel5Layout.setVerticalGroup(
                    panel5Layout.createParallelGroup()
                        .addGroup(panel5Layout.createSequentialGroup()
                            .addGroup(panel5Layout.createParallelGroup()
                                .addGroup(panel5Layout.createSequentialGroup()
                                    .addGap(31, 31, 31)
                                    .addGroup(panel5Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                        .addComponent(label11, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(label12, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(label13, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(textField13, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
                                .addGroup(GroupLayout.Alignment.TRAILING, panel5Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(panel5Layout.createParallelGroup()
                                        .addComponent(textField11, GroupLayout.Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                        .addComponent(textField12, GroupLayout.Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panel5Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label14, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(label15, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(label16, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField14, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField15, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField16, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panel5Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(label17, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(label19, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(label18, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField17, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField18, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField19, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panel5Layout.createParallelGroup()
                                .addComponent(button9)
                                .addGroup(panel5Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(button12)
                                    .addComponent(button10)
                                    .addComponent(button11)))
                            .addGap(18, 18, 18)
                            .addComponent(scrollPane3, GroupLayout.PREFERRED_SIZE, 269, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(25, Short.MAX_VALUE))
                );
            }
            tabbedPane1.addTab("\u7528\u6237", panel5);
        }
        contentPane.add(tabbedPane1, BorderLayout.CENTER);
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JTabbedPane tabbedPane1;
    private JPanel panel3;
    private JLabel label1;
    private JLabel label2;
    private JLabel label3;
    private JLabel label4;
    private JLabel label5;
    private JTextField textField1;
    private JTextField textField2;
    private JTextField textField3;
    private JTextField textField4;
    private JTextField textField5;
    private JButton button1;
    private JButton button2;
    private JButton button3;
    private JButton button4;
    private JScrollPane scrollPane1;
    private JTable table1;
    private JPanel panel4;
    private JLabel label6;
    private JLabel label7;
    private JLabel label8;
    private JTextField textField6;
    private JTextField textField7;
    private JTextField textField8;
    private JTextField textField9;
    private JTextField textField10;
    private JLabel label9;
    private JLabel label10;
    private JButton button5;
    private JButton button6;
    private JButton button7;
    private JButton button8;
    private JScrollPane scrollPane2;
    private JTable table2;
    private JPanel panel5;
    private JLabel label11;
    private JLabel label12;
    private JLabel label13;
    private JLabel label14;
    private JLabel label15;
    private JLabel label16;
    private JLabel label17;
    private JLabel label18;
    private JLabel label19;
    private JTextField textField11;
    private JTextField textField12;
    private JTextField textField13;
    private JTextField textField14;
    private JTextField textField15;
    private JTextField textField16;
    private JTextField textField17;
    private JTextField textField18;
    private JTextField textField19;
    private JButton button9;
    private JButton button10;
    private JButton button11;
    private JButton button12;
    private JScrollPane scrollPane3;
    private JTable table3;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
